A13 - Close Pairs
提出
code: python
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
# print(a)
# 0, 6 -> 3,4
# 1, 6 -> 4
# 2, 6 -> 4,5
# 3, 6 -> 5
for i, v in enumerate(a):
l = i+1
r = n-1
while l < r:
mid = ((r-l) // 2) + l # 違う
l = mid
else:
r = mid
print(l)
解答
code: python
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(0, n-1):
# スタート地点
if i == 0:
else:
# ギリギリまで増やしていく
while ri < n-1 and a[ri+1] - ai <= k: # print(r)
ans = 0
for i in range(0, n-1):
print(ans)